// variable for check children window
var newWindow;


// open new window
function openWin(linkFile, windowWidth, windowHeight) {
	if (windowWidth == undefined) {
		windowWidth = window.screen.width;
	}
	if (windowHeight == undefined) {
		windowHeight = window.screen.height;
	}
//	newWindow = window.open("dialog.jsp?wWidth="+windowWidth+"&wHeight="+windowHeight, "", "menubar=no,toolbar=no,location=no,directory=no,status=no");
	newWindow = window.open(linkFile, "", "menubar=no,toolbar=no,location=no,directory=no,status=no");
	newWindow.resizeTo(windowWidth, windowHeight);
	newWindow.moveTo((window.screen.width-windowWidth)/2, (window.screen.height-windowHeight)/2);
//	callUrl.innerText = linkFile ;
//	dialogWin.mainFrame.location.href=linkFile ;
}

// open report window
function callReport(reportParam) {
	goToReportPage('../servlet/com.epro.standard.frontend.report.EproReportManager?'+reportParam);
}

function goToReportPage(url, windowWidth, windowHeight) {
	if (windowWidth == undefined) {
		windowWidth = window.screen.width;
	}
	if (windowHeight == undefined) {
		windowHeight = window.screen.height;
	}
	reportWin = window.open(url,'','toolbar=0,location=0,menubar=0,resizeable=0,width='+windowWidth+',height='+windowHeight);
//	reportWin.moveTo((window.screen.width-windowWidth)/2, (window.screen.height-windowHeight)/2);
}


// focus in suitable window
function checkFocus() {
	if (newWindow != undefined) {
		window.blur();
		newWindow.focus();
	}
}


// change window size
function changeWindowSize(winObj, windowWidth, windowHeight) {
	winObj.resizeTo(windowWidth, windowHeight);
	winObj.moveTo((window.screen.width-windowWidth)/2, (window.screen.height-windowHeight)/2);
}


// close window
var closeMainWindow = true;
var closeChildWindow = true;
var closeModalWindow = true;
var goToMenu = "EPOS/HSEPMN01.jsp";
//var parentVar = 1;

// close main window
function closeMainWindowOrNot() {
	if(closeMainWindow) {
		window.opener.close();
	} else {
		if (goToMenu != "") {
			window.opener.Menu.location.href = goToMenu;		
		}
		window.opener.focus();
	}
}

// close child window
function closeChildWindowOrNot() {
	if(closeChildWindow) {
		return 'Close Program ?';
	}
}

function closeModalWindowOrNot() {
	if(!closeModalWindow) {
		closeChildWindow = closeModalWindow;
	}
	return closeChildWindowOrNot();
}


// check user press key
function checkKey() {
// variable for return value
returnValue = true;

// use Ctrl key only in Ctrl+A, Ctrl+C, Ctrl+V, Ctrl+X
	if (event.ctrlKey) {
		if (event.ctrlKey && (event.keyCode==65 || event.keyCode==67 || event.keyCode==86 || event.keyCode==88)) {
			returnValue =  true;
		} else {
			returnValue =  false;	
		}
	}

// don't use Alt key
	if (event.altKey) {
		alert("Don't use Alt Key");
		returnValue =  false;
	}

//don't use Backspace Key
	if ((event.srcElement.tagName).toUpperCase() == "INPUT" || (event.srcElement.tagName).toUpperCase() == "TEXTAREA") {
			returnValue =  true;
	} else {
		if (event.keyCode==8) {
//	alert("tagName = "+event.srcElement.tagName);
			alert("Don't use Backspace Key");
			returnValue =  false;
		}
	}

//don't use F1-F12 -- have bug
/*
	if (event.keyCode>=112 && event.keyCode<=123) {
		alert("Don't use F1-F12 Key");
		returnValue =  false;
	}
*/

return returnValue;
}

function hideLayer(layerName) {
		layerName.style.visibility = "hidden";
}